package org.csmzxy.class2334;
class BankAccount {
    private String accountNumber;
    private double balance;

    public void setAccountNumber(String accountNumber) {
        if (accountNumber != null && accountNumber.matches("\\d+")) {
            this.accountNumber = accountNumber;
        } else {
            System.err.println("账号格式错误，应为纯数字");
        }
    }

    public String getAccountNumber() {
        return accountNumber;
    }

    public void setBalance(double balance) {
        if (balance >= 0) {
            this.balance = balance;
        } else {
            System.err.println("输入金额不能为负数");
        }
    }

    public double getBalance() {
        return balance;
    }

    public void broadcast() {
        System.out.println("账户" + accountNumber + "的余额为" + balance + "元");
    }
}

public class Example04 {
    public static void main(String[] args) {
        BankAccount account = new BankAccount();
        account.setAccountNumber("123456");
        account.setBalance(500);
        account.broadcast();
    }
}